﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("----------欢 迎 进 入 游 戏 世 界----------");
            Console.WriteLine("**********************");
            Console.WriteLine("******猜拳，开始******");
            Console.WriteLine("**********************");
            Console.WriteLine("出拳规则：1.剪刀 2.石头 3.布");
            Rule rule = new Rule("剪刀");
            Rule rule2 = new Rule("石头");
            Rule rule3 = new Rule("布");
            Console.WriteLine("请输入对方角色<1.刘备 2.孙权 3.曹操>");
            Role role = new Role("刘备");
            Role role2 = new Role("孙权");
            Role role3 = new Role("曹操");
            int rules = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入您的姓名：");
            string name = Console.ReadLine();
            string names = null;
            if (rules == 1)
            {
                Console.WriteLine($"{name} VS {role.Name} 对战");
                names = role.Name;
            }
            else if (rules == 2)
            {
                Console.WriteLine($"{name} VS {role2.Name} 对战");
                names = role.Name;
            }
            else if (rules == 3)
            {
                Console.WriteLine($"{name} VS {role3.Name} 对战");
                names = role.Name;
            }



            Console.WriteLine("开始游戏吗？（y/n）");
            string yn = Console.ReadLine();
            int num = 0;
            int i = 0;
            int y = 0;
            switch (yn)
            {
                case "y":
                    while (true)
                    {
                        Console.WriteLine("请出拳：1.剪刀 2.石头 3.布（输入相应的数字：）");
                        int rps = int.Parse(Console.ReadLine());
                        if (rps == 1)
                        {
                            Console.WriteLine($"{name}：出拳：剪刀");
                            role.SayHai(); rule.SayHai();
                            if (rule.Gegular == "剪刀")
                            {
                                Console.WriteLine("和局，真晦气！嘿嘿，等着瞧吧！");
                            }
                            if (rule.Gegular == "石头")
                            {
                                Console.WriteLine($"笨蛋，{name}输了");
                                y++;
                            }
                            if (rule.Gegular == "布")
                            {
                                Console.WriteLine($"恭喜，{name}赢了");
                                i++;
                            }

                        }
                        if (rps == 2)
                        {
                            Console.WriteLine($"{name}：出拳：石头");
                            role2.SayHai(); rule2.SayHai();
                            if (rule2.Gegular == "剪刀")
                            {
                                Console.WriteLine($"恭喜，{name}赢了");
                                i++;
                            }
                            if (rule2.Gegular == "石头")
                            {
                                Console.WriteLine("和局，真晦气！嘿嘿，等着瞧吧！");
                                y++;
                            }
                            if (rule2.Gegular == "布")
                            {
                                Console.WriteLine($"笨蛋，{name}输了");
                            }

                        }
                        if (rps == 3)
                        {
                            Console.WriteLine($"{name}：出拳：布");
                            role3.SayHai(); rule3.SayHai();
                            if (rule3.Gegular == "剪刀")
                            {
                                Console.WriteLine($"笨蛋，{name}输了");
                                y++;
                            }
                            if (rule3.Gegular == "石头")
                            {
                                Console.WriteLine($"恭喜，{name}赢了");
                                i++;
                            }
                            if (rule3.Gegular == "布")
                            {
                                Console.WriteLine("和局，真晦气！嘿嘿，等着瞧吧！");
                            }
                        }
                        num++;
                        Console.WriteLine("是否开始下一轮？（y/n）");
                        string ny = Console.ReadLine();
                        if (ny == "y")
                        {

                        }
                        
                        if (ny == "n")
                        {
                            Console.WriteLine("-----------------------------------------");
                            Console.WriteLine($"{name} VS {names}");
                            Console.WriteLine($"对战次数:{num}");
                            Console.WriteLine("姓名     得分");
                            Console.WriteLine($"{name}     {i}");
                            Console.WriteLine($"{names}     {y}");
                            if (i > y)
                            {
                                Console.WriteLine($"{name}赢，{names}笨蛋");
                            }
                            else if (i < y)
                            {
                                Console.WriteLine($"{names}赢，{name}笨蛋");

                            }
                            else if (i==y)
                            {
                                Console.WriteLine("平局");
                            }
                            Console.WriteLine("要开始下一局吗？（y/n）");
                            string aa = Console.ReadLine();
                            if (aa == "y")
                            {
                                Main(null);
                            }
                            else if (aa == "n")
                            {
                                Console.WriteLine("系统退出！！！");
                                break;
                            }
                            break;
                        }
                        
                    }
                    break;
                case "n":
                    Console.WriteLine("系统退出！！！");
                    break;
                default:
                    break;
            }
            Console.ReadLine();
        }

    }
}
